package com.zllkj.mm.adapter

import android.view.LayoutInflater
import android.view.View
import android.widget.CheckBox
import androidx.appcompat.widget.*
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.zllkj.mm.R
import com.zllkj.mm.common.ClientConfig
import com.zllkj.mm.model.entity.OrderListItem
import com.zllkj.mm.module.shopping.vm.ItemMyAddressListVM
import com.zllkj.mm.module.shopping.vm.ItemShoppingCartIListVM
import com.zllkj.mm.util.common.FormatUtil
import kotlinx.android.synthetic.main.fragment_order_confirm.view.*
import java.math.BigDecimal

class MyAddressListAdapter(layoutResId: Int, data: List<ItemMyAddressListVM?>?) :
        BaseQuickAdapter<ItemMyAddressListVM, BaseViewHolder>(layoutResId, data) {


    override fun convert(baseViewHolder: BaseViewHolder, vm: ItemMyAddressListVM) {
        baseViewHolder?.getView<AppCompatTextView>(R.id.tv_order_detail_name)?.text = vm.name
        baseViewHolder?.getView<AppCompatTextView>(R.id.tv_order_detail_phone)?.text = vm.phone
        baseViewHolder?.getView<AppCompatTextView>(R.id.tv_order_detail_address)?.text = vm.address
        if (vm.isModify) {
            baseViewHolder?.getView<AppCompatCheckBox>(R.id.cb_address_list).visibility = View.VISIBLE
            baseViewHolder?.getView<AppCompatImageView>(R.id.iv_item_address_modify).visibility = View.GONE
        } else {
            baseViewHolder?.getView<AppCompatCheckBox>(R.id.cb_address_list).visibility = View.GONE
            baseViewHolder?.getView<AppCompatImageView>(R.id.iv_item_address_modify).visibility = View.VISIBLE
        }
        baseViewHolder?.getView<AppCompatCheckBox>(R.id.cb_address_list).setOnCheckedChangeListener { buttonView, isChecked ->
            vm.isCheck = isChecked
        }


        baseViewHolder?.addOnClickListener(R.id.iv_item_address_modify)

    }


}